/*
	Copyright (c) 2011 Andrey O. Zbitnev (azbitnev@gmail.com)
	Licensed under the MIT License (LICENSE).

	$Id: ys.core.js 3 2012-04-03 12:44:18Z azbitnev@gmail.com $
*/

(function () {

	$.ys = { version: '0.1pa' }

	$.ys.fn = {

		width: function ($selector) {
			var w,
				pl = $selector.css('padding-left'),
				pr = $selector.css('padding-right'),
				wfix = (
					/^[\.0]+(px|em|pt|ex|\%)?$/.test(pl)
					&& /^[\.0]+(px|em|pt|ex|\%)?$/.test(pr)
				)
			if (wfix) {
				w = $selector.css({
					'padding-left': '1px',
					'padding-right': '1px'
				}).outerWidth() - 2
				$selector.css({
					'padding-left': pl,
					'padding-right': pr
				})
			} else {
				w = $selector.outerWidth()
			}
			return w
		},

		height: function ($selector) {
			var h,
				pt = $selector.css('padding-top'),
				pb = $selector.css('padding-bottom'),
				hfix = (
					/^[\.0]+(px|em|pt|ex|\%)?$/.test(pt)
					&& /^[\.0]+(px|em|pt|ex|\%)?$/.test(pb)
				)
			if (hfix) {
				h = $selector.css({
					'padding-top': '1px',
					'padding-bottom': '1px'
				}).outerHeight() - 2
				$selector.css({
					'padding-top': pt,
					'padding-bottom': pb
				})
			} else {
				h = $selector.outerHeight()
			}
			return h
		}
	}
})();

